<?
session_start();
require_once('../twitterlib/twitteroauth/twitteroauth.php');
require_once('../config.php');
require_once('../SQLfunc.php');
require_once('../func.php');

$auth=array();
$gotcha = getAuth($auth);
if(!$gotcha)
{
	die("No token/token secret");
}

/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $auth['token'], $auth['token_secret']);
$content = $connection->get('account/verify_credentials');
$content = $connection->get('favorites', array('screen_name' => $content->screen_name));
$favs = parseFavs($content);
?>


        	<?
			if(empty($favs))
			{
				?><div style="text-align: center; margin-top: 50px;">You don't have any favourite tweet.</div><? }
			else { 		
			$n = 0;
			foreach($favs as $tweet)
			{ $n=$n+1; ?>
        	<div class="tcont">
                <div class="tweet" id="tw<? echo $n; ?>">
                	<img src="<? echo $tweet['avatar']; ?>" class="avatar" />
            		<div class="text">
                    	<a href="http://twitter.com/<? echo $tweet['screen']; ?>" class="username" target="_blank"><? echo $tweet['user']; ?></a><br />
                        <div id="<? echo $tweet['id']; ?>"><? echo $tweet['text']; ?></div>
                    </div>
            		
                    <ul class="controls">
                        <li><img class="tbird" src="../images/bird_16_gray.png" /></li>
                        <li><a href="<? echo $tweet['link']; ?>" target="_blank"><? echo $tweet['date']; ?></a>&nbsp;&nbsp;</li>
                        <li><a href="javascript:void(null)" onclick="showtweetwindow(<? echo "'@".$tweet['screen']." ', '".$tweet['id']; ?>')">Reply</a></li>
                        <li><a href="javascript:void(null)" onclick='showtweetwindow("\"@<? echo $tweet['screen']; ?>: "+document.getElementById("<? echo $tweet['id']; ?>").innerText+"\"", 0)'>Quote</a></li>
                        <li><a href="javascript:void(null)" onclick='twaction("retweet", "<? echo $tweet['id']; ?>")'>Retweet</a>
                        <li><a href="javascript:void(null)" onclick='twaction("unfav", "<? echo $tweet['id']; ?>")'>Unfavorite</a>
                        <li><a href="javascript:void(null)" onclick="showtweetwindow('D <? echo $tweet['screen']; ?> ')">DM</a></li>
						<? if ($tweet['res']) { ?><li class="attcontrol"><a href="javascript:void(null)" id="rc<? echo $n; ?>" class="anim" onclick="animResources('<? echo $n; ?>', '<? echo $tweet['id']; ?>')">Show tweet's attachments</a></li><? } ?>
            		</ul>
                </div>
            </div>
            <? } } ?>
